package com.cjh.weixin.controller;

import com.cjh.common.response.Result;
import com.cjh.common.service.CommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cjh
 * @since 2022-01-22
 */
@RestController
@RequestMapping("/commodity")
public class CommodityController {
    @Autowired
    CommodityService commodityService;
    /*根据门店id获取该门店所有商品*/
    @GetMapping("/getAllCommodityByStoreId")
    public Result getAllCommodityByStoreId(@RequestParam Integer storeId) {
        return commodityService.getAllCommodityByStoreId(storeId);
    }
    /*
    * 根据商品id获取商品信息
    * isMultiSpecification：0时 商品为单规格 直接获取商品信息
    * isMultiSpecification：1时 获取商品和其规格信息
    * */
    @GetMapping("/getCommodityByCommodity")
    public Result getCommodityByCommodity(@RequestParam Integer commodity,@RequestParam Integer isMultiSpecification) {
        return commodityService.getCommodityByCommodity(commodity,isMultiSpecification);
    }


}
